package com.xiyu.service.controller.admin.material;
import com.xiyu.service.vo.material.materialInfo.MaterialInfoUpdateInput;
import com.xiyu.service.vo.material.materialInfo.MaterialInfoCreateInput;
import com.xiyu.service.vo.material.materialInfo.MaterialInfoSingleGetOutput;
import com.xiyu.service.vo.material.materialInfo.MaterialInfoPageQueryOutput;
import com.xiyu.service.vo.material.materialInfo.MaterialInfoPageQueryInput;
import com.xiyu.service.vo.material.materialInfo.MaterialInfoSingleGetCategoryOutput;
import com.xiyu.service.vo.material.materialInfo.MaterialInfoUpdateCategoryInput;
import com.xiyu.service.vo.material.materialInfo.MaterialInfoCreateCategoryInput;
import com.xiyu.service.vo.material.materialInfo.MaterialInfoListQueryCategoryOutput;
import com.xiyu.service.vo.material.materialInfo.MaterialInfoListQueryCategoryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.material.MaterialInfoService;

@Tag(name = "物资信息")
@RestController
@RequestMapping("/material/material-info")
@Validated
public class MaterialInfoController {

    @Resource
    private MaterialInfoService materialInfoService;

    @GetMapping("/list-query-category")
    @Operation(summary = "查询物资类别")
    public CommonResult<List<MaterialInfoListQueryCategoryOutput>> listQueryCategory(@Valid MaterialInfoListQueryCategoryInput inputVO) {
        return success(materialInfoService.listQueryCategory(inputVO));
    }

    @PostMapping("/create-category")
    @Operation(summary = "新增物资类别")
    public CommonResult<Long> createCategory(@Valid @RequestBody MaterialInfoCreateCategoryInput inputVO) {
        return success(materialInfoService.createCategory(inputVO));
    }

    @PutMapping("/update-category")
    @Operation(summary = "更新物资类别")
    public CommonResult<Boolean> updateCategory(@Valid @RequestBody MaterialInfoUpdateCategoryInput inputVO) {
        return success(materialInfoService.updateCategory(inputVO));
    }

    @DeleteMapping("/deleted-category")
    @Operation(summary = "删除物资类别")
    @Parameter(name = "id", description = "物资类别主键ID", example = "")
    public CommonResult<Boolean> deletedCategory(@RequestParam("id") Long id) {
        return success(materialInfoService.deletedCategory(id));
    }

    @GetMapping("/single-get-category")
    @Operation(summary = "获取单个物资类别")
    @Parameter(name = "id", description = "物资类别主键ID", example = "")
    public CommonResult<MaterialInfoSingleGetCategoryOutput> singleGetCategory(@RequestParam("id") Long id) {
        return success(materialInfoService.singleGetCategory(id));
    }

    @GetMapping("/page-query")
    @Operation(summary = "分页查询物资信息")
    @PreAuthorize("@ss.hasPermission('material:info:query')")
    public CommonResult<PageResult<MaterialInfoPageQueryOutput>> pageQuery(@Valid MaterialInfoPageQueryInput inputVO) {
        return success(materialInfoService.pageQuery(inputVO));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个物资信息")
    @Parameter(name = "id", description = "物资信息主键ID", example = "")
    public CommonResult<MaterialInfoSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(materialInfoService.singleGet(id));
    }

    @PostMapping("/create")
    @Operation(summary = "新增物资信息")
    @PreAuthorize("@ss.hasPermission('material:info:create')")
    public CommonResult<Long> create(@Valid @RequestBody MaterialInfoCreateInput inputVO) {
        return success(materialInfoService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新物资信息")
    @PreAuthorize("@ss.hasPermission('material:info:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody MaterialInfoUpdateInput inputVO) {
        return success(materialInfoService.update(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除物资信息")
    @Parameter(name = "id", description = "物资信息主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(materialInfoService.deleted(id));
    }

}
